package com.xxzb.pack0720;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) throws Exception{
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入您的姓名：");
        String name=sc.next();
        System.out.println("请输入您的金额：");
        double score=sc.nextDouble();
        Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql:///gaofeng2207?useSSL=false";
        String username="root";
        String password="1234";
        Connection conn= DriverManager.getConnection(url,username,password);
        String  sql="insert into gaofeng2207.account values (null,(select cardid from gaofeng2207.user where username=?),?)";
        PreparedStatement ps=conn.prepareStatement(sql);
        ps.setString(1,name);
        ps.setDouble(2,score);
        ps.executeUpdate();
        ps.close();
        conn.close();



    }
}
